#ifndef __EVENT_H
#define __EVENT_H

#include "list.h"

struct _event{
    struct list_head h;
    void *data;
    int data_len;
    int (*event_count)();
    int (*event_cb)(void *data,int len);
};


void event_add(struct list_head *h);



#define	SLIST_EMPTY(head)	((head)->slh_first == NULL)

#define	SLIST_FIRST(head)	((head)->slh_first)

#define	SLIST_NEXT(elm, field)	((elm)->field.sle_next)

#define	SLIST_ENTRY(type)						\
struct {								\
	struct type *sle_next;	/* next element */			\
}

#define	SLIST_INSERT_HEAD(head, elm, field) do {			\
	SLIST_NEXT((elm), field) = SLIST_FIRST((head));			\
	SLIST_FIRST((head)) = (elm);					\
} while (0)

#define	SLIST_HEAD(name, type)						\
struct name {								\
	struct type *slh_first;	/* first element */			\
}

#define	SLIST_HEAD_INITIALIZER(head)					\
	{ NULL }

#define	SLIST_FOREACH_SAFE(var, head, field, tvar)			\
	for ((var) = SLIST_FIRST((head));				\
	    (var) && ((tvar) = SLIST_NEXT((var), field), 1);		\
	    (var) = (tvar))    

typedef void (*poll_cb_t)(void *cb_arg);

struct cb_info {
  poll_cb_t cb;
  void *cb_arg;
  SLIST_ENTRY(cb_info) poll_cbs;
};


void event_add_poll_cb_ex(struct cb_info *ci,poll_cb_t cb, void *cb_arg);
void event_add_poll_cb(poll_cb_t cb, void *cb_arg);
int event_poll(int ms) ;


#endif